package com.cet.spring_batch_study.jobs.jsonReader;

import com.cet.spring_batch_study.jobs.xmlReader.Trade;
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.item.adapter.ItemReaderAdapter;
import org.springframework.batch.item.json.JacksonJsonObjectReader;
import org.springframework.batch.item.json.JsonItemReader;
import org.springframework.batch.item.json.builder.JsonItemReaderBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;

import javax.print.DocFlavor;

/**
 * @author NSOC
 */
@Slf4j
@Configuration
public class JsonReaderConfig {

    @Bean
    public JsonItemReader<Trade> jsonItemReader() {
        return new JsonItemReaderBuilder<Trade>()
                .name("tradeJsonItemReader")
                .jsonObjectReader(new JacksonJsonObjectReader<>(Trade.class))
                .resource(new ClassPathResource("trades.json"))
                .build();
    }

}
